package cn.sz.tm.control;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import cn.sz.tm.pojo.User;
import cn.sz.tm.service.UserService;

@Controller
@RequestMapping("/uc")
public class UserController {

	@Autowired
	private UserService userService;
	
	@RequestMapping(value="login",method=RequestMethod.POST)
	public String islogin(User user,HttpServletRequest request) {
		User u = userService.findUserByNameAndPwd(user);
		if(u==null) {
			return "login";
		}else {
			HttpSession session = request.getSession();
			session.setAttribute("myuser", u);
			return "redirect:/firstpage";
		}
		
	}
}
